<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.rawgit.com/konvajs/konva/1.4.0/konva.min.js"></script>
  <meta charset="utf-8">
  <title>Konva Modify Shape Color on Click Demo</title>
  <style>
    body {
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-color: #F0F0F0;
    }
  </style>
</head>
<body>
  <div id="container"></div>
  <script>
    var width = window.innerWidth;
    var height = window.innerHeight;

    var stage = new Konva.Stage({
        container: 'container',
        width: width,
        height: height
    });

    var layer = new Konva.Layer();

    var triangle = new Konva.RegularPolygon({
        x: 80,
        y: 120,
        sides: 3,
        radius: 50,
        fill: '#00D2FF',
        stroke: 'black',
        strokeWidth: 4
    });

    triangle.on('click', function() {
        var fill = this.fill() == 'yellow' ? '#00D2FF' : 'yellow';
        this.fill(fill);
        layer.draw();
    });

    layer.add(triangle);

    var circle = new Konva.Circle({
        x: 180,
        y: 120,
        radius: 50,
        fill: 'red',
        stroke: 'black',
        strokeWidth: 4
    });

    circle.on('click', function() {
        var fill = this.fill() == 'red' ? '#00d00f' : 'red';
        this.fill(fill);
        layer.draw();
    });

    layer.add(circle);
    stage.add(layer);
  </script>

</body>
</html>